def d(l):
    nv = 0
    for j in range(2,l):
        if l%j == 0:
            nv += 1
            break
    if nv == 0:
        return l
    else:
        return 0
    
print("Введите 3 слова через пробел:")
pv = list(map(str,input().split()))
lv = ""
a=["zero","one","two","three","four","five","six","seven","eight","nine"]
for i in range(len(pv)):
    for j in range(len(a)):
        if pv[i] == a[j]:
            lv+=str(j)
nm=1488888888
if len(lv)!=3:
    print("Wrong input")
elif int(lv)== d(int(lv)):
    print(lv)
else:
    lv = int(lv)
    for i in range(lv - 10, lv + 10):
        if (d(int(i)) != 0) and (nm > abs(lv - i)):
            k = i
            nm = abs(lv - i)
    print(k)
